﻿#ifndef PET_H
#define PET_H

#include "BaseObject.h"


#include "GameDefine.h"


#include "../_Global/GlobalClass.h"
//#include "_Global/UIGlobal.h"

#include <QObject>


///////////////////////////////////////////////////////////////////

class _Pet : public _BaseObject
{
    Q_OBJECT
    //Q_FLAGS(_Flags)
    //Q_ENUMS(_ObjType)
    Q_PROPERTY(int id READ id WRITE setId)
    Q_PROPERTY(QString name READ name WRITE setName)
    Q_PROPERTY(int pic READ pic WRITE setPic)
    Q_PROPERTY(int status READ status WRITE setStatus)
    Q_PROPERTY(int exp READ exp WRITE setExp)
    Q_PROPERTY(int maxHP READ maxHP WRITE setMaxHP)
    Q_PROPERTY(int remainHP READ remainHP WRITE setRemainHP)
    Q_PROPERTY(int attack READ attack WRITE setAttack)
    Q_PROPERTY(int defense READ defense WRITE setDefense)
    Q_PROPERTY(int speed READ speed WRITE setSpeed)
    Q_PROPERTY(int luck READ luck WRITE setLuck)
    Q_PROPERTY(int power READ power WRITE setPower)
    Q_PROPERTY(QList<int> magic READ magic)

public:
    enum _JiaoSe
    {
        JiaoSe_NULL,
        JiaoSe_Self,
        JiaoSe_Friend,
        JiaoSe_Enemy
    };

public:
    explicit _Pet(QObject *parent = 0);
    explicit _Pet(const _Pet& pet)
    {
        //*this = pet;
    }
    virtual ~_Pet()
    {

    }

signals:

public slots:



//property
public:

    int id() const
    {
        return m_PetInfo.m_id;
    }
    void setId(int &_V)
    {
        m_PetInfo.m_id = _V;
    }

    QString name() const
    {
        return m_PetInfo.m_name;
    }
    void setName(QString &_V)
    {
        m_PetInfo.m_name = _V;
    }

    int pic() const
    {
        return m_PetInfo.m_pic;
    }
    void setPic(int &_V)
    {
        m_PetInfo.m_pic = _V;
    }

    int status() const
    {
        return m_PetInfo.m_status;
    }
    void setStatus(int &_V)
    {
        m_PetInfo.m_status = _V;
    }

    int exp() const
    {
        return m_PetInfo.m_exp;
    }
    void setExp(int &_V)
    {
        m_PetInfo.m_exp = _V;
    }

    int maxHP() const
    {
        return m_PetInfo.m_maxHP;
    }
    void setMaxHP(int &_V)
    {
        m_PetInfo.m_maxHP = _V;
    }

    int remainHP() const
    {
        return m_PetInfo.m_remainHP;
    }
    void setRemainHP(int &_V)
    {
        m_PetInfo.m_remainHP = _V;
    }

    int attack() const
    {
        return m_PetInfo.m_attack;
    }
    void setAttack(int &_V)
    {
        m_PetInfo.m_attack = _V;
    }

    int defense() const
    {
        return m_PetInfo.m_defense;
    }
    void setDefense(int &_V)
    {
        m_PetInfo.m_defense = _V;
    }

    int speed() const
    {
        return m_PetInfo.m_speed;
    }
    void setSpeed(int &_V)
    {
        m_PetInfo.m_speed = _V;
    }

    int luck() const
    {
        return m_PetInfo.m_luck;
    }
    void setLuck(int &_V)
    {
        m_PetInfo.m_luck = _V;
    }

    int power() const
    {
        return m_PetInfo.m_power;
    }
    void setPower(int &_V)
    {
        m_PetInfo.m_power = _V;
    }

    QList<int> magic() const
    {
        return m_PetInfo.m_magic;
    }




public:
    struct {
        quint32 m_id;
        QString m_name;                //宠物名
        int m_pic;            //图片号,从1开始,0表示无此宠物或战斗时的不存在

        //int m_ill;                //0不忙,1为已选择过,2为生病
        int m_status;           //状态
        //char level;            //级别
        int m_exp;                //战斗经验
        int m_maxHP;                //血上限        //9999
        int m_remainHP;            //剩余血        //9999    0表示死亡或不存在(用这个判断)
        int m_attack;            //攻击        //999
        int m_defense;            //防御
        int m_speed;            //速度
        int m_luck;            //幸运
        int m_power;            //灵力

        //五行
        QList<int> m_magic;
        //int m_Magic[5];        //风攻|土攻|雷攻|水攻|火攻


    }m_PetInfo;

    //战斗中
    public:
        _JiaoSe m_eJiaoSe;
        //战斗中使用的五行下标
        int m_attackProp;
        int m_defentProp;
        QList<int> m_magicHarm;
};





/*
class _Pet : public QObject
{
    Q_OBJECT
    Q_FLAGS(_Flags)
    Q_ENUMS(_ObjType)
    Q_PROPERTY(int id READ id WRITE setId)
    Q_PROPERTY(_ObjType objType READ objType)
    Q_PROPERTY(_Flags flags READ flags WRITE setFlags NOTIFY flagsChanged)
public:
    //int paifu;    //2副牌
    //int huase;    //花色,0=黑桃;1=红桃;2=草花;3=方片
    //int yanse;    //颜色
    //int dianshu;    //点数

    enum _ObjType {
        Type_NULL = -1,                  //无
    };

    enum _Flag {
        Flag_Null = 0,          //无
        Flag_Enable = 2,        //可点
        Flag_Clicked = 4,       //已点

    };
    Q_DECLARE_FLAGS(_Flags, _Flag)        //写在和E1同命名空间下(或同一类中)

    enum _FlagType {
        FlagType_Set,
        FlagType_Add,
        FlagType_Clear
    };


    //所有可 点击/放置 区域
    enum _Area {
        Area_Null = 0,
        Area_PaiDui = 1,   //牌堆
        Area_QiPaiDui = 2, //弃牌堆
        Area_ShouPai = 4,   //手牌区
        Area_PanDing = 8,   //判定区

        Area_WuQi = 16, //装备区
        Area_FangJu = 32, //装备区
        Area_JiaMa = 64, //装备区
        Area_JianMa = 128, //装备区
        Area_ZhuangBei = Area_WuQi | Area_FangJu | Area_JiaMa | Area_JianMa, //装备区

        Area_WuJiang = 256,   //武将区
        Area_JiNeng = 512,   //技能,off
        Area_Button = 1024,   //按钮
    };
    Q_DECLARE_FLAGS(_Areas, _Area)        //写在和E1同命名空间下(或同一类中)

public:
    //int changdu;    //长度
    _Pet()
    {
        setProp();
        init();
    }

    virtual ~_Pet(){}


signals:
    void flagsChanged(_ObjType type, QVariant iID, _Flags flags);


public:
    virtual void init()
    {
        clearSomeFlags(Flag_Null);
        bUsing = false;
    }

    //设置牌的类型和值
    Q_INVOKABLE void setProp(int id = -1, _ObjType type = Type_NULL)
    {
        iID = id;
        eObjType = type;
    }


    _Pet& operator=(_Pet& _t)
    {
        this->iID = _t.iID;
        this->eObjType = _t.eObjType;
        //this->eValue = _t.eValue;
        this->setFlags(_t.eFlags);

        return *this;
    }




//property
    int id() const
    {
        return iID;
    }
    void setId(int &id)
    {
        iID = id;
    }


    _Flags flags() const
    {
        return eFlags;
    }

    void setFlags(_Flags flags)
    {
        if(eFlags != flags) {
            eFlags = flags;
            emit flagsChanged(eObjType,iID,eFlags);
            //qDebug()<<"flagsChanged send"<<eObjType<<iID<<eFlags;
        }
        else
        {
            //emit flagsChanged(eObjType,iID,eFlags);
            //qDebug()<<"flagsChanged send same"<<eObjType<<iID<<eFlags;
        }
    }

    void setflags(_Flags flags,_FlagType type)
    {
        switch (type) {
        case FlagType_Set:
            setFlags(flags);
            break;
        case FlagType_Add:
            setSomeFlags(flags);
            break;
        case FlagType_Clear:
            clearSomeFlags(flags);
            break;
        default:
            break;
        }
    }

    void setSomeFlags(_Flags flags)
    {
        if((eFlags & flags) != flags) {
            eFlags |= flags;
            emit flagsChanged(eObjType,iID,eFlags);
            //qDebug()<<"flagsChanged send";
        }
        else
        {
            //qDebug()<<"flagAChanged send same"<<eObjType<<iID<<eFlags<<flags;
        }
    }
    void clearSomeFlags(_Flags flags)
    {
        if((eFlags & flags) != 0) {
            eFlags ^= flags;
            emit flagsChanged(eObjType,iID,eFlags);
            //qDebug()<<"flagsChanged send";
        }
    }

    _ObjType objType() const
    {
        return eObjType;
    }



public:
    bool        bUsing; //是否使用
protected:
    int         iID;    //ID(下标),一个类型中唯一

    _ObjType    eObjType;  //类型
    _Flags      eFlags;  //状态


};
*/





Q_DECLARE_METATYPE(_Pet*)
//Q_DECLARE_METATYPE(_Pet::_Flags)
//Q_DECLARE_OPERATORS_FOR_FLAGS(_Pet::_Flags)  //写在全局

#endif // PET_H
